home *** CD-ROM | disk | FTP | other *** search
/ Deutsche Edition 1 / Deutsche Edition 1.iso / amok / 081-090 / amok81 / m2 / talkdemo / txt / talker.mod < prev    next >
Text File  |  1993-11-04  |  5KB  |  213 lines

  1. MODULE Talker;
  2. (*$ LargeVars:=FALSE StackParms:=FALSE *)
  3.  
  4. FROM SYSTEM    IMPORT    ADR,ADDRESS,CAST,TAG,LONGSET;
  5. FROM Requester    IMPORT    SetWindow,OKRequest;
  6. FROM String    IMPORT    Length,Copy;
  7. IMPORT    A:Arts,
  8.     ID:IntuitionD,
  9.     IL:IntuitionL,
  10.     GD:GadToolsD,
  11.     GL:GadToolsL,
  12.     ED:ExecD,
  13.     EL:ExecL,
  14.     N:Narrator,
  15.     TB:TalkBase,
  16.     TM:TalkMenu,
  17.     TG:TalkGadgets,
  18.     TN:TalkNarrator,
  19.     TF:TalkFile;
  20.  
  21.  
  22. TYPE
  23.   Str127Ptr=POINTER TO TB.Str127;
  24.   Str255Ptr=POINTER TO TB.Str255;
  25.  
  26. PROCEDURE Talk; FORWARD;
  27.  
  28. PROCEDURE DoMenu(e:TM.ExtItemPtr);
  29. BEGIN
  30.   IF e=NIL THEN
  31.     RETURN
  32.   ELSE
  33.     CASE TM.MenuAction(e^.user) OF
  34.     | TM.openPhonID:
  35.     TF.LoadPhonemes;
  36.     | TM.openVoiceID:
  37.     TF.LoadVoice;
  38.     | TM.savePhonID:
  39.     TF.SavePhonemes;
  40.     | TM.saveVoiceID:
  41.     TF.SaveVoice;
  42.     | TM.talkID:
  43.     Talk;
  44.     | TM.aboutID:
  45.     TB.SetBusy(TRUE);
  46.     OKRequest(
  47.     "    Narrator37 Demo V1.1\n"+
  48.     "© 1992 Bernd Preusing, AMSoft\n"+
  49.     "  Written with M2Amiga V4.1");
  50.     TB.SetBusy(FALSE);
  51.     | TM.quitID:
  52.     TB.quit:=TRUE;
  53.     | TM.resetID:
  54.     TG.SetNarr(TB.defNarr);
  55.     | TM.iconID:
  56.     TB.saveIcons:=ID.checked IN e^.m.flags;
  57.     END;
  58.   END;
  59. END DoMenu;
  60.  
  61. PROCEDURE DoSlider(g:ID.GadgetPtr;code:CARDINAL);
  62. BEGIN
  63.   CASE TG.Gadgets(g^.gadgetID) OF
  64.   | TG.rate:    TB.myNarr.rate:=code;
  65.   | TG.pitch:    TB.myNarr.pitch:=code;
  66.   | TG.volume:    TB.myNarr.volume:=code;
  67.   | TG.sampFreq:TB.myNarr.sampFreq:=code;
  68.   | TG.f0Enth:    TB.myNarr.f0Enthusiasm:=code;
  69.   | TG.f0Perturb:TB.myNarr.f0Perturb:=code;
  70.   | TG.f1Adj:    TB.myNarr.f1Adj:=CAST(INTEGER,code);
  71.   | TG.f2Adj:    TB.myNarr.f2Adj:=CAST(INTEGER,code);
  72.   | TG.f3Adj:    TB.myNarr.f3Adj:=CAST(INTEGER,code);
  73.   | TG.a1Adj:    TB.myNarr.a1Adj:=CAST(INTEGER,code);
  74.   | TG.a2Adj:    TB.myNarr.a2Adj:=CAST(INTEGER,code);
  75.   | TG.a3Adj:    TB.myNarr.a3Adj:=CAST(INTEGER,code);
  76.   | TG.articulate:TB.myNarr.articulate:=code;
  77.   | TG.avBias:    TB.myNarr.avBias:=CAST(INTEGER,code);
  78.   | TG.afBias:    TB.myNarr.afBias:=CAST(INTEGER,code);
  79.   | TG.priority:TB.myNarr.priority:=CAST(INTEGER,code);
  80.   | TG.centralize:TB.myNarr.centralize:=CAST(INTEGER,code);
  81.         IF code=0 THEN
  82.           TG.Disable(TG.centphon);
  83.         ELSE
  84.           TG.Enable(TG.centphon);
  85.         END;
  86.   END;
  87. END DoSlider;
  88.  
  89.  
  90. PROCEDURE EmptyPort(p:ED.MsgPortPtr):BOOLEAN;
  91. BEGIN
  92.   IF p#NIL THEN
  93.     RETURN p^.msgList.head^.succ=NIL;
  94.   ELSE
  95.     RETURN TRUE;
  96.   END;
  97. END EmptyPort;
  98.  
  99. VAR
  100.   aborted:BOOLEAN;
  101.  
  102.  
  103. PROCEDURE DoIntui():BOOLEAN;
  104. VAR
  105.   imp:ID.IntuiMessagePtr;
  106.   class:ID.IDCMPFlagSet;
  107.   code:CARDINAL;
  108.   g:ID.GadgetPtr;
  109.   mi:TM.ExtItemPtr;
  110.   si:ID.StringInfoPtr;
  111.   id:INTEGER;
  112. BEGIN
  113.       imp:=GL.GTGetIMsg(TB.myWindow^.userPort);
  114.       IF imp#NIL THEN
  115.         class:=imp^.class;
  116.         code:=imp^.code;
  117.         g:=imp^.iAddress;
  118.         GL.GTReplyIMsg(imp);
  119.         IF class=ID.IDCMPFlagSet{ID.menuPick} THEN
  120.           IF ~TN.talking THEN
  121.         WHILE ~TB.quit & (code#ID.menuNull) DO
  122.               mi:=CAST(TM.ExtItemPtr,IL.ItemAddress(TM.myMenu,code));
  123.           DoMenu(mi);
  124.           code:=mi^.m.nextSelect;
  125.         END;
  126.       END;
  127.         ELSE (* Gadget *)
  128.           id:=g^.gadgetID;
  129.           IF class<=ID.IDCMPFlagSet{ID.gadgetUp,ID.gadgetDown,ID.mouseMove} THEN
  130.             CASE id OF
  131.             | ORD(TG.rate)..ORD(TG.centralize):
  132.         DoSlider(g,code);
  133.         | ORD(TG.mode):
  134.         TB.myNarr.mode:=code;
  135.         | ORD(TG.sex):
  136.         TB.myNarr.sex:=code;
  137.         | ORD(TG.centphon): (* MX *)
  138.         TG.SetCentPhone(TB.CentrPhons(code));
  139.         | ORD(TG.speak):
  140.         Talk;
  141.         | ORD(TG.text):
  142.         si:=CAST(ID.StringInfoPtr,g^.specialInfo);
  143.         Copy(TB.textBuff,CAST(Str127Ptr,si^.buffer)^);
  144.         IF TN.Translate() THEN
  145.           TG.UpdatePhonemes;
  146.         ELSE
  147.           TB.SetBusy(TRUE);
  148.           OKRequest("Translate error");
  149.           TB.SetBusy(FALSE);
  150.         END;
  151.         | ORD(TG.phonemes):
  152.         si:=CAST(ID.StringInfoPtr,g^.specialInfo);
  153.         Copy(TB.phonBuff,CAST(Str255Ptr,si^.buffer)^);
  154.         Talk;
  155.         | ORD(TG.abort):
  156.         aborted:=TRUE;
  157.         END;
  158.       END;
  159.         END; (* class *)
  160.       END; (* idcmp#NIL *)
  161.       RETURN aborted;
  162. END DoIntui;
  163.  
  164. PROCEDURE Talk;
  165. BEGIN
  166.   IF ~TN.talking THEN
  167.     aborted:=FALSE;
  168.     INCL(TB.myWindow^.flags,ID.rmbTrap);
  169.     TG.Enable(TG.abort);
  170.     TG.Disable(TG.speak); (* vermeide unendliche Rekursion! *)
  171.     TN.DoTalk(DoIntui);
  172.     TG.Enable(TG.speak);
  173.     TG.Disable(TG.abort);
  174.     EXCL(TB.myWindow^.flags,ID.rmbTrap);
  175.   END;
  176. END Talk;
  177.  
  178.  
  179.  
  180. PROCEDURE DoLoop;
  181. BEGIN
  182.   WHILE ~TB.quit DO
  183.     EL.WaitPort(TB.myWindow^.userPort);
  184.     IF DoIntui() THEN END;
  185.   END; (* WHILE *)
  186. END DoLoop;
  187.  
  188. VAR
  189.   si:ID.StringInfoPtr;
  190.  
  191. BEGIN
  192.   TB.quit:=FALSE;
  193.   SetWindow(TB.myWindow);
  194.  
  195.   TG.SetCentPhone(MIN(TB.CentrPhons));
  196.   TG.SetNarr(TB.defNarr); (* von Narr gesetzt *)
  197.  
  198.   IL.ModifyIDCMP(TB.myWindow,TG.idcmpFlags+TM.idcmpFlags);
  199.   TG.Disable(TG.abort);
  200.  
  201.   (* Willkommensgruss *)
  202.   si:=CAST(ID.StringInfoPtr,TG.gadgets[TG.text]^.specialInfo);
  203.   Copy(TB.textBuff,CAST(Str127Ptr,si^.buffer)^);
  204.   IF TN.Translate() THEN
  205.     TG.UpdatePhonemes;
  206.     Talk;
  207.   END;
  208.  
  209.   DoLoop;
  210.  
  211. CLOSE
  212. END Talker.
  213.